/**
 * @format
 * @Author: TC
 * @Last Modified by: TC58:41
 * @Last Modified time: 2025-05-05 01:51:50
 * @Last Modified time: 2025-05-05 01:51:50
 */

import { NavMeshEditor } from "../CCComponent/NavMesh/NavMeshEditor";
import { IV2 } from "../Interface/BaseInterface";
import { SingleBase } from "../Interface/SingleBase";
import { FinalPath } from "../Module/NavMesh/FinalPath";
import { INavCoord, IPathFindingResult } from "../Module/NavMesh/NavInterface";
import { PolygonUnit } from "../Module/NavMesh/PolygonUint";

/**
 * 导航管理类
 */
export class NavMeshManager extends SingleBase {
    public dotList: INavCoord[] = [];
    public polygonList: PolygonUnit[] = [];
    public editor: NavMeshEditor = null;

    private _path: FinalPath = null;

    public static get instance(): NavMeshManager {
        return NavMeshManager._instance
            ? (NavMeshManager._instance as NavMeshManager)
            : (NavMeshManager._instance = new NavMeshManager());
    }

    constructor() {
        super();
        this._path = new FinalPath();
        this.dotList = [];
        this.polygonList = [];
    }

    /**
     * 获取导航路径
     * @param posStart
     * @param posEnd
     */
    public getPath(posStart: IV2, posEnd: IV2): IPathFindingResult {
        return this._path.getPathFindingResust(posStart, posEnd);
    }
}
